(function(vc){
    vc.extends({
        propTypes: {
           emitChooseAffiliateVisit:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseAffiliateVisitInfo:{
                affiliateVisits:[],
                _currentAffiliateVisitName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseAffiliateVisit','openChooseAffiliateVisitModel',function(_param){
                $('#chooseAffiliateVisitModel').modal('show');
                vc.component._refreshChooseAffiliateVisitInfo();
                vc.component._loadAllAffiliateVisitInfo(1,10,'');
            });
        },
        methods:{
            _loadAllAffiliateVisitInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('affiliateVisit.listAffiliateVisit',
                             param,
                             function(json){
                                var _affiliateVisitInfo = JSON.parse(json);
                                vc.component.chooseAffiliateVisitInfo.affiliateVisits = _affiliateVisitInfo.affiliateVisits;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseAffiliateVisit:function(_affiliateVisit){
                if(_affiliateVisit.hasOwnProperty('name')){
                     _affiliateVisit.affiliateVisitName = _affiliateVisit.name;
                }
                vc.emit($props.emitChooseAffiliateVisit,'chooseAffiliateVisit',_affiliateVisit);
                vc.emit($props.emitLoadData,'listAffiliateVisitData',{
                    affiliateVisitId:_affiliateVisit.affiliateVisitId
                });
                $('#chooseAffiliateVisitModel').modal('hide');
            },
            queryAffiliateVisits:function(){
                vc.component._loadAllAffiliateVisitInfo(1,10,vc.component.chooseAffiliateVisitInfo._currentAffiliateVisitName);
            },
            _refreshChooseAffiliateVisitInfo:function(){
                vc.component.chooseAffiliateVisitInfo._currentAffiliateVisitName = "";
            }
        }

    });
})(window.vc);
